home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / bitmas1g / formmain.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-09-03  |  19.2 KB  |  627 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
  4. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  5. Begin VB.Form frmMain 
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   "PC Alarm"
  8.    ClientHeight    =   4860
  9.    ClientLeft      =   45
  10.    ClientTop       =   615
  11.    ClientWidth     =   6975
  12.    LinkTopic       =   "Form2"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   4860
  16.    ScaleWidth      =   6975
  17.    StartUpPosition =   1  'CenterOwner
  18.    Begin VB.PictureBox Picture1 
  19.       BackColor       =   &H00FFFFFF&
  20.       FillColor       =   &H00FFFFFF&
  21.       ForeColor       =   &H00FFFFFF&
  22.       Height          =   375
  23.       Left            =   120
  24.       ScaleHeight     =   315
  25.       ScaleWidth      =   1620
  26.       TabIndex        =   8
  27.       Top             =   4275
  28.       Width           =   1680
  29.       Begin MSComCtl2.UpDown UpDown1 
  30.          Height          =   330
  31.          Left            =   1425
  32.          TabIndex        =   13
  33.          Top             =   0
  34.          Width           =   195
  35.          _ExtentX        =   344
  36.          _ExtentY        =   582
  37.          _Version        =   393216
  38.          Enabled         =   -1  'True
  39.       End
  40.       Begin VB.TextBox txtAmPm 
  41.          Alignment       =   2  'Center
  42.          BorderStyle     =   0  'None
  43.          BeginProperty Font 
  44.             Name            =   "MS Sans Serif"
  45.             Size            =   12
  46.             Charset         =   0
  47.             Weight          =   400
  48.             Underline       =   0   'False
  49.             Italic          =   0   'False
  50.             Strikethrough   =   0   'False
  51.          EndProperty
  52.          Height          =   450
  53.          Left            =   885
  54.          Locked          =   -1  'True
  55.          TabIndex        =   12
  56.          Text            =   "AM"
  57.          Top             =   0
  58.          Width           =   450
  59.       End
  60.       Begin VB.TextBox txtMinute 
  61.          Alignment       =   2  'Center
  62.          BorderStyle     =   0  'None
  63.          BeginProperty Font 
  64.             Name            =   "MS Sans Serif"
  65.             Size            =   12
  66.             Charset         =   0
  67.             Weight          =   400
  68.             Underline       =   0   'False
  69.             Italic          =   0   'False
  70.             Strikethrough   =   0   'False
  71.          EndProperty
  72.          Height          =   450
  73.          Left            =   480
  74.          TabIndex        =   11
  75.          Text            =   "59"
  76.          Top             =   0
  77.          Width           =   345
  78.       End
  79.       Begin VB.TextBox txtHour 
  80.          Alignment       =   2  'Center
  81.          BorderStyle     =   0  'None
  82.          BeginProperty Font 
  83.             Name            =   "MS Sans Serif"
  84.             Size            =   12
  85.             Charset         =   0
  86.             Weight          =   400
  87.             Underline       =   0   'False
  88.             Italic          =   0   'False
  89.             Strikethrough   =   0   'False
  90.          EndProperty
  91.          Height          =   450
  92.          Left            =   0
  93.          TabIndex        =   9
  94.          Text            =   "12"
  95.          Top             =   0
  96.          Width           =   345
  97.       End
  98.       Begin VB.Label Label2 
  99.          Alignment       =   2  'Center
  100.          BackColor       =   &H00FFFFFF&
  101.          Caption         =   ":"
  102.          BeginProperty Font 
  103.             Name            =   "MS Sans Serif"
  104.             Size            =   12
  105.             Charset         =   0
  106.             Weight          =   700
  107.             Underline       =   0   'False
  108.             Italic          =   0   'False
  109.             Strikethrough   =   0   'False
  110.          EndProperty
  111.          Height          =   330
  112.          Left            =   345
  113.          TabIndex        =   10
  114.          Top             =   -15
  115.          Width           =   135
  116.       End
  117.    End
  118.    Begin MSComDlg.CommonDialog CDB 
  119.       Left            =   2025
  120.       Top             =   4095
  121.       _ExtentX        =   847
  122.       _ExtentY        =   847
  123.       _Version        =   393216
  124.    End
  125.    Begin MSComctlLib.ImageList ImageList1 
  126.       Left            =   2010
  127.       Top             =   3420
  128.       _ExtentX        =   1005
  129.       _ExtentY        =   1005
  130.       BackColor       =   -2147483643
  131.       ImageWidth      =   32
  132.       ImageHeight     =   32
  133.       MaskColor       =   12632256
  134.       _Version        =   393216
  135.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  136.          NumListImages   =   7
  137.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  138.             Picture         =   "FormMain.frx":0000
  139.             Key             =   ""
  140.          EndProperty
  141.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  142.             Picture         =   "FormMain.frx":0454
  143.             Key             =   ""
  144.          EndProperty
  145.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  146.             Picture         =   "FormMain.frx":08A8
  147.             Key             =   ""
  148.          EndProperty
  149.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  150.             Picture         =   "FormMain.frx":0D04
  151.             Key             =   ""
  152.          EndProperty
  153.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  154.             Picture         =   "FormMain.frx":1020
  155.             Key             =   ""
  156.          EndProperty
  157.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  158.             Picture         =   "FormMain.frx":1474
  159.             Key             =   ""
  160.          EndProperty
  161.          BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  162.             Picture         =   "FormMain.frx":1790
  163.             Key             =   ""
  164.          EndProperty
  165.       EndProperty
  166.    End
  167.    Begin VB.Timer Timer1 
  168.       Interval        =   200
  169.       Left            =   2070
  170.       Top             =   2865
  171.    End
  172.    Begin VB.Frame Frame1 
  173.       Height          =   4695
  174.       Left            =   1890
  175.       TabIndex        =   3
  176.       Top             =   45
  177.       Width           =   4920
  178.       Begin VB.TextBox txtMessage 
  179.          Height          =   1560
  180.          Left            =   195
  181.          TabIndex        =   18
  182.          Text            =   "Type your message here."
  183.          Top             =   1050
  184.          Width           =   4515
  185.       End
  186.       Begin VB.CommandButton cmdBackColor 
  187.          Caption         =   "Change Back Color"
  188.          Height          =   585
  189.          Left            =   2760
  190.          TabIndex        =   17
  191.          Top             =   2925
  192.          Width           =   1215
  193.       End
  194.       Begin VB.CommandButton cmdActivate 
  195.          Caption         =   "Activate Alarm"
  196.          Height          =   585
  197.          Left            =   825
  198.          TabIndex        =   16
  199.          Top             =   3795
  200.          Width           =   1215
  201.       End
  202.       Begin VB.CommandButton cmdFont 
  203.          Caption         =   "Change Font"
  204.          Height          =   585
  205.          Left            =   825
  206.          TabIndex        =   15
  207.          Top             =   2925
  208.          Width           =   1215
  209.       End
  210.       Begin VB.CommandButton cmdCancel 
  211.          Caption         =   "Cancel"
  212.          Height          =   585
  213.          Left            =   2760
  214.          TabIndex        =   7
  215.          Top             =   3795
  216.          Width           =   1215
  217.       End
  218.       Begin VB.Label lblMsg 
  219.          BackColor       =   &H80000009&
  220.          BorderStyle     =   1  'Fixed Single
  221.          Enabled         =   0   'False
  222.          Height          =   1560
  223.          Left            =   195
  224.          TabIndex        =   6
  225.          Top             =   1050
  226.          Width           =   4515
  227.          WordWrap        =   -1  'True
  228.       End
  229.       Begin VB.Label lblCurrent 
  230.          BorderStyle     =   1  'Fixed Single
  231.          Caption         =   "No current action defined"
  232.          Height          =   285
  233.          Left            =   195
  234.          TabIndex        =   5
  235.          Top             =   510
  236.          Width           =   4515
  237.       End
  238.       Begin VB.Label Label1 
  239.          AutoSize        =   -1  'True
  240.          Caption         =   "Current Action"
  241.          Height          =   195
  242.          Left            =   180
  243.          TabIndex        =   4
  244.          Top             =   240
  245.          Width           =   1005
  246.       End
  247.    End
  248.    Begin VB.CommandButton cmdMessage 
  249.       Caption         =   "Message"
  250.       Height          =   945
  251.       Left            =   330
  252.       Style           =   1  'Graphical
  253.       TabIndex        =   2
  254.       Tag             =   "Message"
  255.       Top             =   2535
  256.       Width           =   1215
  257.    End
  258.    Begin VB.CommandButton cmdSound 
  259.       Caption         =   "Sound"
  260.       Height          =   945
  261.       Left            =   345
  262.       Style           =   1  'Graphical
  263.       TabIndex        =   1
  264.       Tag             =   "Sound"
  265.       Top             =   1335
  266.       Width           =   1200
  267.    End
  268.    Begin VB.CommandButton cmdProgram 
  269.       Caption         =   "Program"
  270.       Height          =   945
  271.       Left            =   330
  272.       Style           =   1  'Graphical
  273.       TabIndex        =   0
  274.       Tag             =   "Program"
  275.       Top             =   135
  276.       Width           =   1215
  277.    End
  278.    Begin VB.Label Label3 
  279.       AutoSize        =   -1  'True
  280.       Caption         =   "Set Time"
  281.       BeginProperty Font 
  282.          Name            =   "MS Sans Serif"
  283.          Size            =   13.5
  284.          Charset         =   0
  285.          Weight          =   400
  286.          Underline       =   0   'False
  287.          Italic          =   0   'False
  288.          Strikethrough   =   0   'False
  289.       EndProperty
  290.       Height          =   360
  291.       Left            =   375
  292.       TabIndex        =   14
  293.       Top             =   3795
  294.       Width           =   1125
  295.    End
  296.    Begin VB.Menu mnuFile 
  297.       Caption         =   "&File"
  298.       Begin VB.Menu mnuFileProgram 
  299.          Caption         =   "Set &Program"
  300.       End
  301.       Begin VB.Menu mnuFileSound 
  302.          Caption         =   "Set &Sound"
  303.       End
  304.       Begin VB.Menu mnuFileMessage 
  305.          Caption         =   "Set &Message"
  306.       End
  307.       Begin VB.Menu mnuFileSep 
  308.          Caption         =   "-"
  309.       End
  310.       Begin VB.Menu mnuFileExit 
  311.          Caption         =   "E&xit"
  312.       End
  313.    End
  314.    Begin VB.Menu mnuAbout 
  315.       Caption         =   "&About"
  316.    End
  317. Attribute VB_Name = "frmMain"
  318. Attribute VB_GlobalNameSpace = False
  319. Attribute VB_Creatable = False
  320. Attribute VB_PredeclaredId = True
  321. Attribute VB_Exposed = False
  322. Option Explicit
  323. Dim hour As Boolean
  324. Dim min As Boolean
  325. Dim ampm As Boolean
  326. Private Sub Command1_Click()
  327.  ' fmainform is defined in the module
  328.    fMainForm.WindowState = 1
  329.     Load frmMessage
  330.     Call SetUpForm(frmMessage)
  331.     frmMessage.Show
  332. End Sub
  333. Private Sub Form_Load()
  334.     ' set all the icons on the command buttons
  335.     cmdProgram.Picture = ImageList1.ListImages(1).Picture
  336.     cmdProgram.DisabledPicture = ImageList1.ListImages(4).Picture
  337.     cmdMessage.Picture = ImageList1.ListImages(2).Picture
  338.     cmdMessage.DisabledPicture = ImageList1.ListImages(5).Picture
  339.     cmdSound.Picture = ImageList1.ListImages(3).Picture
  340.     cmdSound.DisabledPicture = ImageList1.ListImages(6).Picture
  341.     ' set the forms icon
  342.     frmMain.Icon = ImageList1.ListImages(7).Picture
  343.      
  344.     ' disable the timer
  345.     Timer1.Enabled = False
  346.     Call SetDefaults
  347. End Sub
  348. Private Sub cmdProgram_Click()
  349.     ' process the cancel button
  350.     ' this forces an error if the user presses the cancel button
  351.     CDB.CancelError = True
  352.     On Error GoTo ErrHandler
  353.     ' clear the the filename
  354.     CDB.FileName = ""
  355.     ' set filters
  356.     CDB.Filter = "Program Files (*.exe)|*.exe"
  357.     ' display the dialog box
  358.     CDB.ShowOpen
  359.     ' show the selection in current action label
  360.     lblCurrent.Caption = "Run Program"
  361.     lblMsg.Visible = True
  362.     txtMessage.Visible = False
  363.     lblMsg.Caption = CDB.FileName
  364.     cmdSound.Enabled = False
  365.     cmdMessage.Enabled = False
  366.     cmdCancel.Enabled = True
  367.     cmdActivate.Enabled = True
  368.     ' use the command buttons tag
  369.     index = cmdProgram.Tag
  370.     ' exit the sub here if user pressed ok
  371.     Exit Sub
  372.         
  373. ErrHandler:
  374.     Call SetDefaults
  375.     Exit Sub
  376. End Sub
  377. Private Sub cmdSound_Click()
  378.     CDB.CancelError = True
  379.     On Error GoTo ErrHandler
  380.     CDB.FileName = ""
  381.     CDB.Filter = "Wav Files (*.wav)|*.wav"
  382.     CDB.ShowOpen
  383.     lblCurrent.Caption = "Play Sound"
  384.     lblMsg.Visible = True
  385.     txtMessage.Visible = False
  386.     lblMsg.Caption = CDB.FileName
  387.     cmdProgram.Enabled = False
  388.     cmdMessage.Enabled = False
  389.     cmdCancel.Enabled = True
  390.     cmdActivate.Enabled = True
  391.     index = cmdSound.Tag
  392.     Exit Sub
  393. ErrHandler:
  394.     Call SetDefaults
  395.     Exit Sub
  396. End Sub
  397. Private Sub cmdMessage_Click()
  398.         
  399.     txtMessage.Visible = True
  400.     txtMessage.SetFocus
  401.     txtMessage.SelStart = 0
  402.     txtMessage.SelLength = txtMessage.Width
  403.         
  404.     lblMsg.Visible = False
  405.     lblCurrent.Caption = "Display custom message"
  406.     cmdFont.Enabled = True
  407.     cmdBackColor.Enabled = True
  408.     cmdProgram.Enabled = False
  409.     cmdSound.Enabled = False
  410.     cmdCancel.Enabled = True
  411.     cmdActivate.Enabled = True
  412.     index = cmdMessage.Tag
  413. End Sub
  414. Private Sub cmdFont_Click()
  415.     ' **** NOTE ****
  416.     ' since i am using a 'textbox' the font size of 72 doesn't show up
  417.     ' i could have used another control ... but on my system i never use
  418.     ' a font that big anyways :)
  419.     CDB.CancelError = True
  420.     On Error GoTo ErrHandler
  421.     CDB.Flags = cdlCFBoth Or cdlCFEffects
  422.     CDB.ShowFont
  423.     'update the label box to the users selections
  424.     txtMessage.Font.Size = CDB.FontSize
  425.     txtMessage.Font.Bold = CDB.FontBold
  426.     txtMessage.Font.Italic = CDB.FontItalic
  427.     txtMessage.Font.Underline = CDB.FontUnderline
  428.     txtMessage.Font.Strikethrough = CDB.FontStrikethru
  429.     Exit Sub
  430. ErrHandler:
  431.     Exit Sub
  432. End Sub
  433. Private Sub cmdBackColor_Click()
  434.     CDB.CancelError = True
  435.     On Error GoTo ErrHandler
  436.     CDB.Flags = cdlCCFullOpen
  437.     CDB.ShowColor
  438.     ' change the label to the users selection
  439.     txtMessage.BackColor = CDB.Color
  440.     Exit Sub
  441. ErrHandler:
  442.     Exit Sub
  443. End Sub
  444. Private Sub cmdActivate_Click()
  445.     fMainForm.WindowState = 1
  446.     Timer1.Enabled = True
  447.     Call Timer1_Timer
  448. End Sub
  449. Private Sub cmdCancel_Click()
  450.     Call SetDefaults
  451. End Sub
  452. Private Sub Form_Unload(Cancel As Integer)
  453.     End
  454. End Sub
  455. Private Sub mnuFileProgram_Click()
  456.     Call cmdProgram_Click
  457. End Sub
  458. Private Sub mnuFileSound_Click()
  459.     Call cmdSound_Click
  460. End Sub
  461. Private Sub mnuFileMessage_Click()
  462.     Call cmdMessage_Click
  463. End Sub
  464. Private Sub mnuFileExit_Click()
  465.     End
  466. End Sub
  467. Private Sub mnuAbout_Click()
  468.     Dim msg As String
  469.     msg = "PC Alarm" & vbCrLf & _
  470.               "Written by John Meller" & vbCrLf & _
  471.               "Questions, suggestions or comments" & vbCrLf & _
  472.               "e-mail me at jmeller@istar.ca"
  473.               
  474.     MsgBox msg, vbInformation + vbOKOnly, "PC Alarm: About"
  475.        
  476. End Sub
  477. Private Sub SetDefaults()
  478.     ' set up the lblmsg with all the defaults
  479.     With lblMsg
  480.         .Caption = ""
  481.         .BackColor = vbWhite
  482.         .Visible = True
  483.         .Font = "MS Sans Serif"
  484.         .FontBold = False
  485.         .FontItalic = False
  486.         .FontSize = 8
  487.         .FontStrikethru = False
  488.         .FontUnderline = False
  489.         .ForeColor = vbBlack
  490.     End With
  491.     lblCurrent.Caption = "No current action defined."
  492.     'disable the uneeded buttons
  493.     cmdFont.Enabled = False
  494.     cmdBackColor.Enabled = False
  495.     cmdActivate.Enabled = False
  496.     cmdCancel.Enabled = False
  497.     ' disable the textbox
  498.     txtMessage.Visible = False
  499.     ' and enable the needed buttons
  500.     cmdProgram.Enabled = True
  501.     cmdSound.Enabled = True
  502.     cmdMessage.Enabled = True
  503.      
  504. End Sub
  505. Private Sub Timer1_Timer()
  506.     Dim strTemp As String
  507.     Dim strSetTime As String
  508.     Dim strTime As String
  509.     strTemp = txtHour.Text & ":" & txtMinute.Text & txtAmPm.Text
  510.     strSetTime = Format(strTemp, "hh:nn AM/PM")
  511.     strTime = Format(Time, "hh:nn AM/PM")
  512.     If strSetTime = strTime Then
  513.         Call ActivateAlarm(index)
  514.         Exit Sub
  515.     End If
  516. End Sub
  517. Private Sub txtAmPm_Click()
  518.     txtAmPm.SelStart = 0
  519.     txtAmPm.SelLength = txtAmPm.Width
  520.     hour = False
  521.     min = False
  522.     ampm = True
  523. End Sub
  524. Private Sub txtHour_Click()
  525.     txtHour.SelStart = 0
  526.     txtHour.SelLength = txtHour.Width
  527.     hour = True
  528.     min = False
  529.     ampm = False
  530. End Sub
  531. Private Sub txtminute_Click()
  532.     txtMinute.SelStart = 0
  533.     txtMinute.SelLength = txtMinute.Width
  534.     hour = False
  535.     min = True
  536.     ampm = False
  537. End Sub
  538. Private Sub UpDown1_DownClick()
  539.     If hour = True Then
  540.         With UpDown1
  541.             .min = 1
  542.             .Max = 12
  543.             .Increment = 1
  544.             .Wrap = True
  545.         End With
  546.         If UpDown1.Value <= 9 Then
  547.             'put a leading 0 in front
  548.             txtHour.Text = "0" & UpDown1.Value
  549.         Else
  550.             txtHour.Text = UpDown1.Value
  551.         End If
  552.     End If
  553.     If min = True Then
  554.         With UpDown1
  555.             .min = 0
  556.             .Max = 59
  557.             .Increment = 1
  558.             .Wrap = True
  559.         End With
  560.         
  561.         If UpDown1.Value <= 9 Then
  562.             txtMinute.Text = "0" & UpDown1.Value
  563.         Else
  564.             txtMinute.Text = UpDown1.Value
  565.         End If
  566.      
  567.     End If
  568.     If ampm = True Then
  569.         With UpDown1
  570.             .min = 1
  571.             .Max = 2
  572.             .Increment = 1
  573.             .Wrap = True
  574.         End With
  575.         
  576.         If UpDown1.Value = 1 Then
  577.             txtAmPm.Text = "AM"
  578.         Else
  579.             txtAmPm.Text = "PM"
  580.         End If
  581.     End If
  582.         
  583. End Sub
  584. Private Sub UpDown1_UpClick()
  585.     If hour = True Then
  586.         With UpDown1
  587.             .min = 1
  588.             .Max = 12
  589.             .Increment = 1
  590.             .Wrap = True
  591.         End With
  592.         If UpDown1.Value <= 9 Then
  593.             txtHour.Text = "0" & UpDown1.Value
  594.         Else
  595.             txtHour.Text = UpDown1.Value
  596.         End If
  597.      End If
  598.     If min = True Then
  599.         With UpDown1
  600.             .min = 0
  601.             .Max = 59
  602.             .Increment = 1
  603.             .Wrap = True
  604.         End With
  605.         If UpDown1.Value <= 9 Then
  606.             txtMinute.Text = "0" & UpDown1.Value
  607.         Else
  608.             txtMinute.Text = UpDown1.Value
  609.         End If
  610.      End If
  611.     If ampm = True Then
  612.         With UpDown1
  613.             .min = 1
  614.             .Max = 2
  615.             .Increment = 1
  616.             .Wrap = True
  617.         End With
  618.         
  619.         If UpDown1.Value = 1 Then
  620.             txtAmPm.Text = "AM"
  621.         Else
  622.             txtAmPm.Text = "PM"
  623.         End If
  624.     End If
  625.         
  626. End Sub
  627.